lib: Add URL override pull option
authorKrzesimir Nowak <krzesimir@kinvolk.io>
Tue, 19 Apr 2016 09:32:14 +0000 (11:32 +0200)
committerColin Walters (automation) <walters+githubbot@verbum.org>
Fri, 22 Apr 2016 14:27:06 +0000 (14:27 +0000)
The "override-url" option allows to use the other URL while still
using some options from the passed remote.

Closes: #271
Approved by: cgwalters

src/libostree/ostree-repo-pull.c
src/libostree/ostree-repo.c

index 968b5951d2cde8728b42b72f49e5d56ae27c25c5..708df5b65b0a13336d8a959af817f9fa863008a7 100644 (file)
@@ -1909,6 +1909,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
   gboolean require_static_deltas = FALSE;
   gboolean opt_gpg_verify = FALSE;
   gboolean opt_gpg_verify_summary = FALSE;
+  const char *url_override = NULL;
 
   if (options)
     {
@@ -1926,6 +1927,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
       (void) g_variant_lookup (options, "require-static-deltas", "b", &require_static_deltas);
       (void) g_variant_lookup (options, "override-commit-ids", "^a&s", &override_commit_ids);
       (void) g_variant_lookup (options, "dry-run", "b", &pull_data->dry_run);
+      (void) g_variant_lookup (options, "override-url", "&s", &url_override);
     }
 
   g_return_val_if_fail (pull_data->maxdepth >= -1, FALSE);
@@ -2021,7 +2023,9 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
     {
       g_autofree char *baseurl = NULL;
 
-      if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error))
+      if (url_override != NULL)
+        baseurl = g_strdup (url_override);
+      else if (!ostree_repo_remote_get_url (self, remote_name_or_baseurl, &baseurl, error))
         goto out;
 
       pull_data->base_uri = soup_uri_new (baseurl);
index 35bc3a5d5a20826c8831c0ae09c82813cfbd8494..97233d3d7fe192fd102ff36d5c9362eddc42d9bb 100644 (file)
@@ -4077,6 +4077,7 @@ ostree_repo_pull_one_dir (OstreeRepo               *self,
  *   * require-static-deltas (b): Require static deltas
  *   * override-commit-ids (as): Array of specific commit IDs to fetch for refs
  *   * dry-run (b): Only print information on what will be downloaded (requires static deltas)
+ *   * override-url (s): Fetch objects from this URL if remote specifies no metalink in options
  */
 gboolean
 ostree_repo_pull_with_options (OstreeRepo             *self,